<?php
require("cfg.php");
require("function.php");
if (isset($_POST['list_name']) && strlen($_POST['list_name']) > 0) {
	
	$list_name=$_POST['list_name'];
	$user_name="test_user";
	$ip=get_ip();
	$sql="SELECT `id` FROM `user_list` WHERE `list_name` = '$list_name'AND `user_name` = '$user_name';";
	mysql_query($sql);
	if (mysql_affected_rows()== 0){
	
	$sql="INSERT INTO `user_list` ( `id` , `list_name` , `user_name` , `creat_time` , `ip` ) VALUES (NULL , '$list_name', '$user_name', NOW( ) , '$ip');";
	mysql_query($sql);
	$sql="SELECT `id` FROM `user_list` WHERE `list_name` = '$list_name'AND `user_name` = '$user_name';";
	$query=mysql_query($sql);
	$row = mysql_fetch_array($query);
	echo $row['id'];
	}
	else echo -1;
}

?>